﻿#ifndef SALEQUERYWIDGET_H
#define SALEQUERYWIDGET_H

#include <QWidget>
#include "userrelation.h"
#include "userpicker.h"
#include "productpicker.h"
#include "salequerystandarditemmodel.h"
#include "dingdanservice.h"
#include "dingdandetailwidget.h"

namespace Ui {
class SaleQueryWidget;
}

class SaleQueryWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SaleQueryWidget(QWidget *parent = nullptr);
    ~SaleQueryWidget();

    void setWidgetType(SaleQueryStandardItemModel::WidgetType widgetType);

private slots:
    void on_comboBoxQueryType_currentIndexChanged(int index);

    void on_pushButtonClear_clicked();

    void on_pushButtonQuery_clicked();

    void on_comboBoxTicket_currentIndexChanged(int index);

    void on_comboBoxMoney_currentIndexChanged(int index);

    void on_dateEditStartTime_dateChanged(const QDate &date);

    void on_dateEditEndTime_dateChanged(const QDate &date);

    void on_pushButtonDetail_clicked();

private:
    Ui::SaleQueryWidget *ui;
    UserRelation::RelationType widgetType;
    SaleQueryStandardItemModel model;
    DingdanService dingdanService;
    QList<Dingdan*> dingdans;
    QList<DingdanAndDetail*> details;

    UserPicker userPicker;
    ProductPicker productPicker;
    DingdanDetailWidget dingdanDetailWidget;

    UserRelation *relation;
    Product *product;
    int type;

    QDate lastStartDate;
    QDate lastEndDate;
};

#endif // SALEQUERYWIDGET_H
